home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
ww_tv.exe
/
TEDITOR4.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1992-01-06
|
7KB
|
180 lines
/****************************************************************************/
/* */
/* Copyright (c) 1991 Primatech Inc. */
/* */
/* All Rights Reserved */
/* */
/****************************************************************************/
// $config$=/MTEditor4.cpp
//
// $NAME$:
// ..Module Overview
//
// $GLOBAL PATHS$
// modules\all\TEditor4.cpp
// modules\c++\TEditor4.cpp
// objects\TEditor
//
// $0$
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// Purpose: Word wrap function for TEditor
//
// Prototypes location: $/SEE(Editors.h)$
//
// Other Information:
//
// See also: $/SEE()$
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//$-1$
#if 0
//$1$
/**** MODIFICATIONS HISTORY ****/
Created: 12 November 1991 by John L. Swartzentruber
$SKIP START$
#endif
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*+ +*/
/*+ I N C L U D E F I L E S +*/
/*+ +*/
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#define Uses_TEditor
#include <tv.h>
//$SKIP END$
//$2$
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*+ +*/
/*+ # D E F I N E S C L A S S E S and T Y P E D E F S +*/
/*+ +*/
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
//$3$
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*+ +*/
/*+ E X T E R N A L D E F I N I T I O N S +*/
/*+ +*/
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
//$4$
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*+ +*/
/*+ S T A T I C D E F I N I T I O N S +*/
/*+ +*/
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
//$END$
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*+ +*/
/*+ S T A T I C F U N C T I O N P R O T O T Y P E S +*/
/*+ +*/
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/* EJECT */
//****************************************************************************
//
// Function $NAME$:
// TEditor::wordWrapBuffer(ushort,ushort)
// $1$
//
// Purpose: To word wrap the buffer. This is always done, regardless
// of the value of wordWrap. Consequently, don't call this
// function if wordWrap is False.
//
// Parameters:
//
// ushort linePtr: Where word-wrapping should begin. This
// is an offset into the buffer, and it MUST
// be the beginning of a line. This will
// usually be the beginning of the line before
// the line containing curPtr.
//
// ushort minchars: The minumum number of characters that the
// word wrapping function will process before
// deciding that there is nothing to wrap. This
// should usually be set to ensure that the
// current line (and any new data) are checked.
//
//
// Return: The WordWrapState (wwsDidWrap, wwsNoWrap, wwsError)
//
// Other information:
//
// This function handles an error by calling the editorDialog with
// an out of memory error.
//
//$0$
//****************************************************************************
WordWrapState TEditor::wordWrapBuffer(ushort linePtr, ushort minchars)
// $END$
{
short line_delta = 0;
WordWrapState wrap_rc = doWordWrapBuffer(linePtr, minchars, &line_delta);
if (wrap_rc == wwsError) {
editorDialog( edOutOfMemory );
} else if (wrap_rc == wwsDidWrap) {
// If we wrapped, completely recalculate which line we are on
curPos.y = countLines(buffer, curPtr);
drawLine = curPos.y;
drawPtr = lineStart(curPtr);
curPos.x = charPos(drawPtr, curPtr);
limit.y += line_delta;
delta.y = max(0, min(delta.y, limit.y - size.y));
delta.x = max(curPos.x - size.x + 1, 0);
update(ufView);
}
return wrap_rc;
}
/* EJECT */
//****************************************************************************
//
// Function $NAME$:
// TEditor::changeBufSize(short)
// $1$
//
// Purpose: This is a non-virtual function that calls the virtual
// function setBufSize(). It is defined so that an
// assembly language function can easily call the virtual
// function to increase or decrease the size of the buffer.
//
// Return: same as setBufSize() (True on success, False on failure)
//
// Other information:
//
//$0$
//****************************************************************************
Boolean TEditor::changeBufSize( short change )
// $END$
{
return setBufSize(bufSize + change);
}